/// If we list all the natural numbers below 10 that are multiples of 3 or 5,
/// we get 3, 5, 6 and 9. The sum of these multiples is 23.
/// Find the sum of all the multiples of 3 or 5 below 1000.

/// sum of filtered list
let sum_of_cond ls pred =
  ls
  |> List.filter pred
  |> List.sum

/// test whether m is divisable by n
let divisableBy n m = m % n = 0

/// If we list all the natural numbers below 10 that are multiples of 3 or 5,
/// we get 3, 5, 6 and 9. The sum of these multiples is 23.
let example =
  sum_of_cond [1..9] (fun n -> divisableBy 3 n || divisableBy 5 n)

/// the sum of all the multiples of 3 or 5 below 1000.
let solution =
  sum_of_cond [1..999] (fun n -> divisableBy 3 n || divisableBy 5 n)

/// print example and solution
let main =
  printf "%A\n" example
  printf "%A\n" solution
